package impl;
import anaydis.sort.SorterType;
import com.sun.istack.internal.NotNull;

import java.util.Comparator;
import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: Keevu
 * Date: 13/09/11
 * Time: 18:39
 * To change this template use File | Settings | File Templates.
 */

public class ShellSorter extends HSorter {
    private List<Integer> h;


    public ShellSorter() {
        super(SorterType.SHELL);
        h = new ArrayList<Integer>();
        h.add(9841);
        h.add(3280);
        h.add(1093);
        h.add(364);
        h.add(121);
        h.add(40);
        h.add(13);
        h.add(4);
        h.add(1);


    }

    public void setHList(List<Integer> h){
        this.h = h;
    }

    public <T> void sort(@NotNull Comparator<T> tComparator, @NotNull List<T> ts) {
        sort(tComparator, ts, h);
    }

    private <T> void sort(@NotNull Comparator<T> tComparator, @NotNull List<T> ts, List<Integer> h) {
        for (Integer aH : h) {
           setH(aH);
           miniSort(tComparator, ts);
        }
        new BubbleSorter().sort(tComparator, ts);
    }

}